package Work20241108;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author zdl
 * @date 2024/11/8
 */
public class Demo9 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] arr = {100, 90, 98, 97, 96, 95, 94, 93};
        int minIndex = 0;
        int maxIndex = 0;
        for (int i = 1; i < arr.length; i++) {

            if (arr[minIndex] > arr[i]){
                minIndex = i; //最小值下标
            }
        }
        System.out.println(minIndex);
        System.out.println(maxIndex);

        System.out.println(Arrays.toString(arr));
        //移除最小值
        for (int i = minIndex; i < arr.length -1; i++) {
            arr[i] = arr[i+1];
        }
        System.out.println("asdas:"+Arrays.toString(arr));
        int[] arr_1 = new int[arr.length-1];
        for (int i = 0; i < arr_1.length; i++) {
            arr_1[i] = arr[i];
        }
        System.out.println("移除最小值后的数组："+Arrays.toString(arr_1));

        //以移除最小值后的数组arr_1为基础，移除最大值
        /**
         * i =2 2<2 false
         * i=0 0<2
         *      a2[0]= arr[0]
         */
        for (int i = 0; i < arr_1.length; i++) {
            if(arr_1[maxIndex] < arr_1[i]){
                maxIndex = i;
            }
        }
        for (int i = maxIndex; i < arr_1.length ; i++) {
            arr[i] = arr[i+1];
        }
        int[] arr_2 = new int[arr_1.length-1];
        for (int i = 0; i < arr_1.length-1; i++) {
            arr_2[i] = arr[i];
        }
        System.out.println(Arrays.toString(arr_2));
    }
    }

